<template>
  <view @touchmove.stop.prevent="moveHandle">
    <view
      v-show="show"
      class="uni-mask"
      :style="'background-color:' + bgRgba + ';'"
      :class="{ 'uni-mask-order': type == 'order', 'uni-mask-pick': type == 'pick' }"
    ></view>
    <view
      v-show="show"
      :class="['uni-popup', 'uni-popup-' + type]"
      :style="{
        width: width ? width + 'rpx' : '',
        overflow: overflow ? overflow + '' : 'hidden',
        background: bgColor ? bgColor + '' : '#ffffff',
      }"
    >
      <view v-if="!hideClose" class="close" @tap="hide">
        <slot name="close-icon">
          <server-image
            class="close-icon"
            name="popupIconCancel2.png"
            mode="widthFix"
          ></server-image>
        </slot>
      </view>
      <slot></slot>
      <view v-if="hideBtnClose" class="close-btm" @tap="hide">
        <slot name="close-btm">
          <server-image class="btm-icon" name="group20210722004.png" mode="widthFix"></server-image>
        </slot>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    show: {
      type: Boolean,
      default: false,
    },
    hideBtnClose: {
      type: Boolean,
      default: false,
    },
    type: {
      type: String,
      //top - 顶部， middle - 居中, bottom - 底部
      default: 'middle',
    },
    width: {
      type: Number,
      default: 0,
    },
    hideClose: {
      type: Boolean,
      default: false,
    },
    overflow: {
      type: String,
      //top - 顶部， middle - 居中, bottom - 底部
      default: 'hidden',
    },
    bgColor: {
      type: String,
      //top - 顶部， middle - 居中, bottom - 底部
      default: '#ffffff',
    },
    bgRgba: {
      type: String,
      //top - 顶部， middle - 居中, bottom - 底部
      default: 'rgba(0, 0, 0, .3)',
    },
  },
  data() {
    return {};
  },
  methods: {
    hide: function () {
      this.$emit('hide');
    },
  },
};
</script>
<style lang="less" scoped>
.uni-mask {
  position: fixed;
  z-index: 996;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: rgba(0, 0, 0, 0.3);
}

.close-btm {
  margin: 0 auto;

  .btm-icon {
    width: 30px;
    height: 30px;
    display: block;
    margin: 0 auto;
  }
}

.uni-popup {
  position: fixed;
  z-index: 996;
  // background-color: #ffffff;
  /*box-shadow: 0 0 30upx rgba(0, 0, 0, .1);*/
}

.uni-popup-middle {
  width: 640upx;
  //min-height: 300upx;
  border-radius: 20upx;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  justify-content: center;
  /*padding: 30upx;*/
  overflow: hidden;
}

// 弹框顶部可超出
.uni-popup-middle-top {
  width: 620upx;
  //min-height: 300upx;
  border-radius: 30upx;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  justify-content: center;
  /*padding: 30upx;*/
  overflow: initial;
}

.uni-popup-top {
  top: 88upx;
  left: 0;
  width: 100%;
  height: 100upx;
  line-height: 100upx;
  text-align: center;
}

.uni-popup-bottom {
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100upx;
  line-height: 100upx;
  text-align: center;
}

.close {
  position: absolute;
  right: 40upx;
  top: 40upx;
  z-index: 100;

  .close-icon {
    width: 30upx;
    height: 30upx;
    display: block;
  }
}

.uni-popup-order {
  width: 690upx;
  //min-height: 300upx;
  border-radius: 20upx;
  top: 50%;
  left: 50%;
  margin: -400upx 0 0 -345upx;
  // 长列表用transform会模糊，改用margin
  // transform: translate(-50%, -50%);
  justify-content: center;
  /*padding: 30upx;*/
  overflow: hidden;
  z-index: 999;
}

.uni-mask-order {
  z-index: 999;
}

.uni-mask-pick {
  z-index: 1000;
}

.uni-popup-pick {
  width: 640upx;
  //min-height: 300upx;
  border-radius: 20upx;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  justify-content: center;
  /*padding: 30upx;*/
  overflow: hidden;
  z-index: 1000;
}
</style>
